# simple guess a number game

# reads one character, skipping control chars (newlines and such)
readChar:
  @@
    <-

    $0 " " >= ? # space char is lowest "normal" char
      !@
    ;
      ^
    .
  .
.

0 10 "Please enter a seed character for my pseudo random number generator:" -->

readChar

11 * 3 + 13 * 1 + 17 * 2 + 10 % "0" + # convert to pseudorandom "0" to "9" value

$0 # duplicate it for writing out in case of bad guess

0 10 "I am thinking a number from 0 to 9 (including), type your guess:" --> 

readChar

= ?
  0 "You guessed it!" -->
;
  0 "No, it was " -->
  -> "." ->
.

10 ->
